/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.            */
/*                                                                 */
/*  NAME      = t_sqlserver_frbindata_destory.c                    */
/*  NOTE      =                                                    */
/*  DATE      = 2014/12/09 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <string.h>
#include <CUnit/Basic.h>

#include <frcomm.h>
#include <sqlserver/config.h>
#include <sqlserver/sqlserver_core.h>
#include <sqlserver/sqlserver_common.h>

static int __suite_init(void)
{

	return 0;
}

static int __suite_cleanup(void)
{

	return 0;
}

static void __case1(void)
{
    Frbindata **pp_st_frbindata;

    pp_st_frbindata = NULL;

    sqlserver_frbindata_destory(pp_st_frbindata);

    return;
}

static void __case2(void)
{
    Frbindata *p_st_frbindata = NULL;

    sqlserver_frbindata_destory(&p_st_frbindata);

    return;
}

static void __case3(void)
{
    Frbindata *p_st_frbindata = NULL;
    char *p_tmp = NULL;

    p_tmp = (char *) frmalloc(strlen("test") + 1);
    snprintf(p_tmp,strlen("test") + 1,"%s","test");

    p_st_frbindata = (Frbindata *) frmalloc(sizeof(Frbindata));
    p_st_frbindata->p_data = p_tmp;
    p_st_frbindata->ui_len = strlen("test");

    sqlserver_frbindata_destory(&p_st_frbindata);

    CU_ASSERT_PTR_NULL(p_st_frbindata);

    return;
}

int add_suite_sqlserver_frbindata_destory(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" sqlserver_frbindata_destory()", __suite_init, __suite_cleanup)) == NULL)
    return FR_FAIL;

    //增加测试用例
    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL ||
        CU_add_test(pSuite, "case3", __case3) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
